﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;
using System.Collections.Generic;
using System.Xml.Linq;
using System.Xml;
using System.Linq;

namespace GreekWP7
{
    public class KeyInfo
    {
        public string Value { get; set; }
        public string Accent { get; set; }
        public string Caps { get; set; }
    }


    public static class KeyboardInfoUtilities
    {
        static KeyboardInfoUtilities()
        {
            LoadLanguages();
            LoadSpecialCharacters();
        }

        public static void LoadLanguages()
        {
                XDocument doc = XDocument.Load(@"xml\languages.xml");
                foreach (XElement xe2 in doc.Element("LanguageDetails").Elements())
                {
                    string key = xe2.Attribute("key").Value;
                    Languages.Add(key, new Dictionary<string, KeyInfo>());
                    foreach (XElement xe3 in xe2.Elements())
                    {
                        KeyInfo ki = new KeyInfo() { Value = xe3.Attribute("Value").Value, Caps = xe3.Attribute("Caps").Value };
                        if(xe3.Attribute("Accent") != null)                        
                            ki.Accent = xe3.Attribute("Accent").Value;                        
                        else
                            ki.Accent=null;

                        Languages[key].Add(xe3.Attribute("ID").Value, ki);
                    }
                }
        }

        public static void LoadSpecialCharacters()
        {
            XDocument doc = XDocument.Load(@"xml\specialCharacters.xml");
            foreach (XElement xe2 in doc.Element("SpecialCharacters").Elements())
            {
                SpecialCharacters.Add(xe2.Attribute("ID").Value, new KeyInfo()
                {
                    Value = xe2.Attribute("Value").Value,
                    Caps = xe2.Attribute("Caps").Value
                });
            }
        }

        public static Dictionary<string, KeyInfo> SpecialCharacters = new Dictionary<string, KeyInfo>();
        public static Dictionary<string, Dictionary<string, KeyInfo>> Languages = new Dictionary<string, Dictionary<string, KeyInfo>>();

    }
}
